<template>
  <div>
    <div class="search-pannel">
      <el-form class="search-form" ref="searchForm" label-position="top" :model="searchData">
        <el-col :span="6">
          <el-form-item label="房屋标题" prop="name">
            <el-input v-model="searchData.name" placeholder="请输入房屋标题"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="房屋地址" prop="address">
            <el-input v-model="searchData.address" placeholder="请输入房屋地址"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="最小租金" prop="minRent">
            <el-input v-model.number="searchData.minRent" placeholder="请输入房屋地址"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="最大租金" prop="maxRent">
            <el-input v-model.number="searchData.maxRent" placeholder="请输入房屋地址"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="地区" prop="areaId">
            <el-cascader
                ref="cascader"
                v-model="area_temp"
                :options="areaList"
                :props="areaDefaultProps"
                @change="handleChange(), (searchData.areaId = areaIds.join(','))"
            ></el-cascader>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="状态" prop="status">
            <el-select v-model="searchData.status">
              <el-option v-for="item in houseStatusList" :key="item.value" :value="item.value"
                         :label="item.text"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="创建时间" prop="createdAt">
            <el-date-picker v-model="searchData.createdAt" type="daterange"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <div class="button-list">
            <el-button type="primary" @click="onSearch">搜 索</el-button>
            <el-button @click="reset(),area_temp=''">重 置</el-button>
          </div>
        </el-col>
      </el-form>
    </div>
    <page-table
        ref="pageTable"
        showIndex
        @currentChange="currentChange"
        @sizeChange="sizeChange"
        @sortChange="sortChange"
        :loading="loading"
        :data="data"
        :total="count"
        :page="pageIndex"
        :pageSize="pageSize"
    >
      <el-table-column prop="name" show-overflow-tooltip label="房屋标题"></el-table-column>
      <el-table-column prop="rent" sortable="custom" show-overflow-tooltip label="房屋租金"></el-table-column>
      <el-table-column prop="areaName" show-overflow-tooltip label="所在地区"></el-table-column>
      <el-table-column prop="OwnerNickName" show-overflow-tooltip label="房东名"></el-table-column>
      <el-table-column show-overflow-tooltip label="住客名">
        <template slot-scope="{row}">
          {{(row.leases && row.leases.length && row.leases[0].user && row.leases[0].user.nickName)||'暂无'}}
        </template>
      </el-table-column>
      <el-table-column sortable="custom" prop="createdAt" label="创建时间">
        <template slot-scope="{row}">
          {{row.createdAt | timeFilter}}
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="{row}">
          {{row.status | houseStatusFilter}}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{row}">
          <el-button type="text" @click="toDetail(row.id)">详情</el-button>
        </template>
      </el-table-column>
    </page-table>
    <detail-dialog :visible="detailVisible" @close="detailClose" :opId="opId" />
  </div>
</template>

<script>
import { initTable, getHouseStatus, getAllArea } from '@/mixins'
import { _getList } from './store'

export default {
  name: 'houseSetting',
  mixins: [initTable, getHouseStatus, getAllArea],
  data() {
    return {
      searchData: {
        name: '',
        address: '',
        minRent: '',
        maxRent: '',
        areaId: '',
        status: '',
        createdAt: []
      },
      initFunc: _getList
    }
  },
  components: {
    'detailDialog': () => import('../components/detailDialog')
  }
}
</script>

<style scoped>

</style>
